<template>
  <div>
    <van-cell>
      <van-image
        slot="icon"
        round
        width="30"
        height="30"
        style="margin-right: 10px;"
        :src="item.aut_photo"
      />
      <span style="color: #466b9d;" slot="title">{{item.aut_name}}</span>
      <div slot="label">
        <p style="color: #363636;">{{item.content}}</p>
        <p>
          <span style="margin-right: 10px;">{{item.pubdate | format}}</span>
          <van-button size="mini" type="default" @click="replyBtn">回复{{item.reply_count}}</van-button>
        </p>
      </div>
      <van-button
        slot="right-icon"
        :class="{liked:item.is_liking}"
        :icon="item.is_liking ?'good-job': 'good-job-o'"
        @click="zanBtn"
      >{{item.like_count ?item.like_count : '赞'}}==={{item.is_liking}}</van-button>
    </van-cell>
  </div>
</template>
           
<script>
import { addLike_api, delLike_api } from "@/api/article/index";
export default {
  props: {
    item: {
      type: [Array, Object],
      required: true
    }
  },
  data() {
    return {};
  },
  methods: {
    //点赞按钮---------------------------
    async zanBtn() {
      // console.log(this.item,99999);
      var is_like = this.item.is_liking;
      var com_id = this.item.com_id;
      if (is_like) {
        const { data: res } = await delLike_api(com_id);
        this.item.like_count='';
        console.log(res, 666);
      } else {
        const { data: res } = await addLike_api(com_id);
        item.like_count=1;
      }
      this.item.is_liking = !this.item.is_liking;
    },
    //点击回复-----显示弹出层
    replyBtn() {
      // console.log(333333);
      this.$emit('replyBtn',this.item)
    }
  }
};
</script>
<style scoped lang="less">
.comment-item {
  .avatar {
    width: 72px;
    height: 72px;
    margin-right: 25px;
  }
  .title-wrap {
    display: flex;
    justify-content: space-between;
    align-items: center;
    .user-name {
      color: #406599;
      font-size: 26px;
    }
  }
  .comment-content {
    font-size: 32px;
    color: #222222;
    word-break: break-all;
    text-align: justify;
  }
  .comment-pubdate {
    font-size: 19px;
    color: #222;
    margin-right: 25px;
  }
  .bottom-info {
    display: flex;
    align-items: center;
  }
  .reply-btn {
    width: 135px;
    height: 48px;
    line-height: 48px;
    font-size: 21px;
    color: #222;
  }
 .like-btn {
    height: 25px;
    padding: 0;
    border: none;
    font-size: 19px;
    line-height: 30px;
    margin-right: 7px;
   

    .van-icon {
      font-size: 30px;
    }
  }
  /deep/.liked { 
      color: orangered;
    }
}
</style>